package com.sh.xxj.rebot.app;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.hn.comm.Tools;
import com.sh.xxj.rebot.model.CourseModel;
import com.sh.xxj.rebot.model.CourseOptionModel;
import com.sh.xxj.rebot.model.TypeModel;
import com.sh.xxj.rebot.service.CourseService;

/**
 * 删除脏图片
 * @author Administrator
 *
 */
public class DeleteDirtyPic {
	public static void main(String[] args) throws Exception {
		CourseService cs = new CourseService();
		List<TypeModel> listTypeModel = cs
				.getTypeModeFromFilePath("D:\\tmp\\menu.xml");

		List<CourseOptionModel> listCOM=new ArrayList<CourseOptionModel>();
		
		HashMap<String, String> mapPics=new HashMap<String, String>();
		
		for (TypeModel tm : listTypeModel) {
			for(CourseModel cm:tm.getListCourseModel())
			{
				listCOM.addAll(cm.getListCourseOptionModel());
			}
		}
		
		for(CourseOptionModel com:listCOM)
		{
			mapPics.put(com.getPic().trim(), com.getPic().trim());
		}
		
		
		
		System.out.println("总数:"+listCOM.size());
		
		//---------------------------------------------------------------------------------------------------
		String courseStuff="D:\\tmp\\course_stuff";
		
		File[] files=Tools.readAllFile(courseStuff);
		System.out.println("总共文件有:"+files.length);
		for(File file:files)
		{
			String fileName=file.getName().trim();
//			System.out.println("文件名:"+fileName);
			int iStart=fileName.indexOf(".");
			fileName=fileName.substring(0, iStart);
//			System.out.println("文件名2:"+fileName);
			if(mapPics.containsKey(fileName))
			{
				
			}
			else
			{
				System.out.println("删除:"+file.getName().trim());
				file.delete();
			}

		}

	}
	
	private static boolean hasPic()
	{
		return false;
	}
}
